package WaiBao;

import java.util.Arrays;

public class ZhangXiangYu {
    public static void main(String[] args) {
        String[] name = {"谢霆锋(班长)", "李晨(副班长)", "小李(学习委员)", "郑凯(体育委员)", "蔡徐坤", "洪小刚", "成龙", "洪金宝", "梁朝伟", "周传雄", "华晨宇", "吕子乔",
                "杨超伟", "周杰伦", " 隔壁老樊", "王北车", "蔡健雅", "孙燕姿", "许嵩", "杨洋", "汪苏泷", "王靖雯", "于文文", "辣椒", "王大胖", "王境泽", "肖战", "黄子韬",
                "张艺兴", "张祥玉(学生)"};//考生本人: 张祥玉(学生)
        int[] age = {18, 19, 20, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};
        double[] B1 = {88, 82, 64, 90, 69, 69, 78, 89, 80, 90, 90, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 74, 74, 80, 93};
        double[] B2 = {78, 75, 69, 76, 78, 67, 88, 69, 90, 60, 90, 77, 86, 95, 65, 65, 66, 79, 66, 78, 72, 71, 95, 85, 75, 84, 84, 64, 90, 93};
        double[] B3 = {75, 96, 80, 95, 79, 69, 78, 69, 80, 80, 93, 87, 85, 75, 65, 68, 69, 99, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 94};

        double DD;//代表每个学生的总分
        double AB;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            DD = B1[i] + B2[i] + B3[i];
//            AB = (DD * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + DD);
//            System.out.println(name[i] + "的平均分为:" + AB);
//        }


//        double Ret = 0, pp = 0;
//        double[] cunchu = new double[30];
//        for (int i = 0; i < 30; i++) {
//           Ret = B1[i] + B2[i] + B3[i];
//            pp = (Ret * 1.0) / 3;
//            cunchu[i] = pp;
//        }

//        for (int i = 0; i < cunchu.length - 1; i++) {
//            for (int j = 0; j < cunchu.length - i - 1; j++) {
//                if (cunchu[j] < cunchu[j + 1]) {
//                    double tep = cunchu[j];
//                    cunchu[j] = cunchu[j + 1];
//                    cunchu[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(cunchu[i]);
//        }


        double f1 = 0, f2 = 0, f3 = 0;//计算每门课的平均分
        double k1 = 0, k2 = 0, k3 = 0;//计算每门课标准差
        double n1 = 0, n2 = 0, n3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < B1.length; i++) {
            he += B1[i];
        }
        f1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + f1);
        double Sum = 0;
        for (int i = 0; i < B2.length; i++) {
            Sum += B2[i];
        }
        f2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与制造的班级平均分为:" + f2);
        double sum = 0;
        for (int i = 0; i < B3.length; i++) {
            sum += B3[i];
        }
        f3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + f3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < B1.length; i++) {
            c1 += (B1[i] - f1) * (B1[i] - f1);
        }
        k1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + k1);
        for (int i = 0; i < B2.length; i++) {
            c2 += (B2[i] - f2) * (B2[i] - f2);
        }
        k2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:" + k2);

        for (int i = 0; i < B3.length; i++) {
            c3 += (B3[i] - f3) * (B3[i] - f3);
        }
        k3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:" + k3);
//
//
//
        Arrays.sort(B1);
        Arrays.sort(B2);
        Arrays.sort(B3);
        n1 =( B1[15]+B1[14])*1.0/2;
        n2 =( B2[15]+B2[14])*1.0/2;
        n3 =( B3[15]+B3[14])*1.0/2;
        System.out.println("生物化学的中位数为:"+n1);
        System.out.println("微生物学的中位数为:"+n2);
        System.out.println("人体组织解剖学的中位数为:"+n3);

    }
}
